<template>
  <div class="page-container">
    <a-tabs>
      <a-tab-pane key="car-info" title="门店信息">
        <store-info :info="form" />
      </a-tab-pane>
      <a-tab-pane key="shortSiteConfig" title="自驾短租配置" v-if="userServiceTypes.includes(1)">
        <service-config v-if="form.shortSiteConfig" configType="shortSiteConfig" :info="form.shortSiteConfig" key="1" />
        <a-empty style="margin-top: 20vh" v-else>
          <template #image>
            <icon-exclamation-circle-fill />
          </template>
          暂未配置
        </a-empty>
      </a-tab-pane>
      <a-tab-pane key="longSiteConfig" title="自驾长租配置" v-if="userServiceTypes.includes(2)">
        <service-config v-if="form.longSiteConfig" configType="longSiteConfig" :info="form.longSiteConfig" key="2" />
        <a-empty style="margin-top: 20vh" v-else>
          <template #image>
            <icon-exclamation-circle-fill />
          </template>
          暂未配置
        </a-empty>
      </a-tab-pane>
      <a-tab-pane key="3" title="操作记录">
        <OperateLog :id="routePrams.id" type="10" />
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script setup name="StoreManageDetail">
  import { ref, provide } from 'vue'
  import { useRoute } from 'vue-router'
  import { getSiteLeaseDetail } from '@/api/asset/site'
  import { getEnterpriseDetail } from '@/api/asset/enterprise.js'
  import serviceConfig from './components/service-config.vue'
  import storeInfo from './components/store-info.vue'
  import { usePageDict } from '@/hooks/useDict'
  const carsiteDict = usePageDict('carsiteDict')
  provide('dict', carsiteDict)
  let form = ref({
    shortSiteConfig: {},
    longSiteConfig: {},
    carHouseKeepNameList: [],
  })
  const route = useRoute()
  const routePrams = route.params
  if (routePrams.id) {
    // 获取门店详情
    getSiteLeaseDetail({ id: routePrams.id }).then((res) => {
      if (res.code == 200) {
        const result = res.result
        // 门店坐标
        result.lnglat = `${result.longitudeGd},${result.latitudeGd}`
        form.value = result
      }
    })
  }

  // 企业信息
  let userServiceTypes = ref([])
  getEnterpriseDetail().then((res) => {
    if (res.code == 200) {
      const result = res.result
      userServiceTypes.value = result.userServiceTypes
    }
  })
</script>

<style lang="less" scoped></style>
